package com.yejiarong.weather.agent.controller;

import com.yejiarong.weather.agent.service.IWeatherRegionCodeService;
import com.yejiarong.common.tools.HttpResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author YeJR
 */
@RestController
@RequestMapping(value = "/regionCode")
public class WeatherRegionCodeController {

    private final IWeatherRegionCodeService weatherRegionCodeService;

    public WeatherRegionCodeController(IWeatherRegionCodeService weatherRegionCodeService) {
        this.weatherRegionCodeService = weatherRegionCodeService;
    }


    /**
     * 保存天气区域编码
     * @param regionCodeMap 省 -> 市 -> 区 -> 编码
     * @return HttpResult
     */
    @PostMapping(value = "/save")
    public HttpResult<Void> saveWeatherRegionCode(@RequestBody Map<String, Map<String, Map<String, String>>> regionCodeMap) {
        weatherRegionCodeService.saveWeatherRegionCode(regionCodeMap);
        return HttpResult.success();
    }

}
